package com.sharkpro.designPattern.myIterator;

import javax.sound.midi.Soundbank;
import java.util.Iterator;

/**
 * @author jianxin.wei
 * @description
 * @date 2024/12/16 16:45
 */
public class Main {
    public static void main(String[] args) {
        BookShelf bookShelf = new BookShelf();
        bookShelf.appendBook(new Book("A"));
        bookShelf.appendBook(new Book("B"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("C"));
        bookShelf.appendBook(new Book("D"));
        MyIterator iterator = bookShelf.iterator();
        while (iterator.hasNext()){
            Book book = (Book) iterator.next();
            System.out.println(book.getName());
        }
        System.out.println("===================================");
        MyIterator iteratorPre = bookShelf.iteratorPre();
        while (iteratorPre.hasNext()){
            Book book = (Book) iteratorPre.next();
            System.out.println(book.getName());
        }
        System.out.println("===================================");
        MyIterator iteratorTwo = bookShelf.iteratorTwo();
        while (iteratorTwo.hasNext()){
            Book book = (Book) iteratorTwo.next();
            System.out.println(book.getName());
        }



    }
}
